package chapter11;

import typeinfo.pets.Pet;
import typeinfo.pets.Pets;
import typeinfo.pets.Rat;

import java.util.LinkedList;
import static net.mindview.util.Print.*;

/**
 * Created by VIC.Huang on 2017/1/22.
 */
public class LinkedListFeatures {
    public static void main(String[] args) {
        LinkedList<Pet> pets = new LinkedList<Pet>(Pets.arrayList(5));
        print(pets);
        /*
        the methods of get element: getFirst/element/peek
         */
        // Identical:
        print("pets.getFirst():" + pets.getFirst());
        print("pets.element():" + pets.element());
        // Only differs in empty-list behavior
        print("pets.peek():" + pets.peek());

        /*
        the methods of remove element: remove/removeFirst/poll
         */
        // Identical: remove and return the first element
        print("pets.remove():" + pets.remove());
        print("pets.removeFirst():" + pets.removeFirst());
        // Only differs in empty-list behavior
        print("pets.poll():" + pets.poll());
        print(pets);

        /*
        the methods of add element: addFirst/offer/add/addLast
         */
        pets.addFirst(new Rat());
        print("After addFirst():" + pets);
        pets.offer(Pets.randomPet());
        print("After offer():" + pets);
        pets.add(Pets.randomPet());
        print("After add():" + pets);
        pets.addLast(Pets.randomPet());
        print("After addLast():" + pets);
        print("pets.removeLast():" + pets.removeLast());
    }
}
